package com.sms.sendservice.controller;


import com.sms.common.result.Result;
import com.sms.sendservice.annotation.GlobalRateLimit;
import com.sms.sendservice.annotation.GuavaRateLimit;
import com.sms.sendservice.service.SmsSendService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SmsSendController {

    @Resource
    private SmsSendService smsSendService;

    // 添加全局限流注解，使用默认资源名"user-service-global"
    @GlobalRateLimit
    @GetMapping("/sms/send/{id}")
    public Result sendSms(@PathVariable Long id) {
        // 业务逻辑（无需再写限流代码）
        return smsSendService.sendSms("123", "Test message", 1L, id);
    }

    @GuavaRateLimit(qps = 50)
    @GetMapping("/sms/send/{taskId}")
    public Result sendSmsTask(@PathVariable Long taskId) {
        // 业务逻辑（无需再写限流代码）
        return smsSendService.sendSms("123", "Test message", 1L, taskId);
    }
}